package com.edyd.customer.api.service;


import com.edyd.customer.api.config.CacheKey;
import com.edyd.customer.api.domain.Customer;
import com.fow.core.database.mybatis.service.BaseService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;


@Service
public class CustomerService extends BaseService<Customer> {


    public Customer selectByPhoneNum(String phoneNumber){

        Map<String, Object> query = new HashMap<String, Object>();
        query.put("phone",phoneNumber);
        Customer customer = this.selectOne(query);

        if(customer == null)
            return null;

        return customer;
    }


    @Cacheable(value="customer")
    public Object getFromCache(@CacheKey int customerId) {
        return null;
    }


    @CachePut(value = "customer")
    public Customer updateCache(Customer customer,@CacheKey int customerId) {

        return customer;
    }


    @CacheEvict(value = "customer")
    public void deleteCache(Customer customer,@CacheKey int customerId) {
    }
}